import type { FormList, SearchList } from "@/types/form";
import type { TableColumn, TableOptions } from "@/types/public";
import { FORM_REQUIRED } from "@/utils/config";

// 搜索数据
export const searchList = (): SearchList[] => [
    {
        label: "船名",
        name: "name",
        component: "Input",
    },
    {
        label: "轮船编号",
        name: "number",
        component: "Input",
    },
    {
        label: "船主姓名",
        name: "name2",
        component: "Input",
    },
];

/**
 * 表格数据
 * @param optionRender - 渲染操作函数
 */
export const tableColumns = (optionRender: TableOptions<object>): TableColumn[] => {
    return [
        {
            title: "ID",
            dataIndex: "id",
            width: 100,
        },
        {
            title: "船名",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "轮船编号",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "额定载重",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "船主姓名",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "船主电话",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "添加日期",
            dataIndex: "content",
            width: 150,
        },
        {
            title: "操作",
            dataIndex: "operate",
            width: 200,
            render: (value: unknown, record: object) => optionRender(value, record),
        },
    ];
};

// 新增数据
export const createList = (): FormList[] => [
    {
        label: "轮船编号",
        name: "username1",
        rules: FORM_REQUIRED,
        component: "Input",
    },
    {
        label: "船名",
        name: "username2",
        rules: FORM_REQUIRED,
        component: "Input",
    },
    {
        label: "额定载重",
        name: "username3",
        component: "Input",
    },
    {
        label: "船主姓名",
        name: "username4",
        component: "Input",
    },
    {
        label: "船主电话",
        name: "username5",
        component: "Input",
    },
];
